package com.hxzy.controller;

import com.hxzy.common.RabbitMQConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TopicExchangeController {
    /**
     * rabbit封装好的消息发送的模板类
     */
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping(value = "/topic/send")
    public String topicSendMsg(String key){
        //发送消息
        this.rabbitTemplate.convertAndSend(RabbitMQConst.SHOP_TOPIC_EXCHANGE,key, "topic"+Math.random());
        return "topic-exchange发送消息成功";
    }
}
